package com.example.http.httpclient;

import java.io.InputStream;

import org.apache.commons.digester.Digester;
import org.xml.sax.InputSource;




/**
 * 大赢家响应返回的XML的JAVA对象
 * */
public class ActionResultXML {
	
	private String xMsgID;
	
	private String xCode;
	
	private String xMessage;
	
	private String xSign;
	
	private String xValue;
	
	@Override
	public String toString() {
		StringBuffer sb=new StringBuffer();
		sb.append("xMsgID:").append(xMsgID).append("\n").
		append("xCode:").append(xCode).append("\n").
		append("xMessage:").append(xMessage).append("\n").
		append("xSign:").append(xSign).append("\n").
		append("xValue:").append(xValue);
		return sb.toString();
	}
	
	
	/**
	 * @param inputStream 输入流
	 * @param encoding 流的编码方式
	 * @return XML的相对类
	 * @throws Exception
	 */
	public static ActionResultXML getInstance(InputStream inputStream,String encoding) throws Exception{
		Digester d = new Digester();
		d.setValidating(false);
		d.addObjectCreate("ActionResult", ActionResultXML.class);
		d.addCallMethod("ActionResult/xMsgID", "setXMsgID",0);
		d.addCallMethod("ActionResult/xCode", "setXCode",0);
		d.addCallMethod("ActionResult/xMessage", "setXMessage",0);
		d.addCallMethod("ActionResult/xSign", "setXSign",0);
		d.addCallMethod("ActionResult/xValue", "setXValue",0);
		InputSource inputSource=new InputSource(inputStream);
		inputSource.setEncoding(encoding);
		return (ActionResultXML)d.parse(inputSource);
	}
	

	public String getXMsgID() {
		return xMsgID;
	}

	public void setXMsgID(String msgID) {
		xMsgID = msgID;
	}

	public String getXCode() {
		return xCode;
	}

	public void setXCode(String code) {
		xCode = code;
	}

	public String getXMessage() {
		return xMessage;
	}

	public void setXMessage(String message) {
		xMessage = message;
	}

	public String getXSign() {
		return xSign;
	}

	public void setXSign(String sign) {
		xSign = sign;
	}

	public String getXValue() {
		return xValue;
	}

	public void setXValue(String value) {
		xValue = value;
	}
}
